package com.demotest.util;

public class StringUtil {
    public static boolean isEmpty(Object strVal) {
        return strVal == null || safeTrim(strVal).isEmpty();
    }

    public static boolean isNotEmpty(Object strVal) {
        return !isEmpty(strVal);
    }

    public static String safeToString(Object obj) {
        return obj == null ? "" : obj.toString();
    }

    public static String safeTrim(Object obj) {
        char[] charArr = safeToString(obj).toCharArray();
        for (int i = 0; i < charArr.length && (charArr[i] <= ' ' || charArr[i] == 12288); i++) {
            if (charArr[i] == 12288) {
                charArr[i] = ' ';
            }
        }
        for (int i2 = charArr.length - 1; i2 >= 0 && (charArr[i2] <= ' ' || charArr[i2] == 12288); i2--) {
            if (charArr[i2] == 12288) {
                charArr[i2] = ' ';
            }
        }
        return new String(charArr).trim();
    }

    public static String toStringWithEmpty(Object inObject) {
        return inObject == null ? "" : inObject.toString();
    }
}
